package com.kd.juhaowan.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;


import com.hjq.http.EasyHttp;
import com.hjq.http.listener.HttpCallbackProxy;
import com.kd.juhaowan.R;
import com.kd.juhaowan.http.api.CommonApi;
import com.kd.juhaowan.http.model.HttpData;
import com.kd.juhaowan.http.model.InviteModel;
import com.kd.juhaowan.ui.dialog.InviteConfirmDialog;
import com.kd.juhaowan.ui.listener.OnItemClickListener;

import butterknife.BindView;
import butterknife.OnClick;

public class InviteActivity extends BaseActivity  implements OnItemClickListener {


    @BindView(R.id.activity_title)
    TextView titleView;

    @BindView(R.id.invite_persion)
    TextView peopleView;
    @BindView(R.id.invite_money)
    TextView moneyView;






    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        titleView.setText("邀请好友");

       initdata();
    }

    @Override
    protected void reInitDate() {
        initdata();
    }

    private void initdata(){
        EasyHttp.post(this).api(new CommonApi("api/promotion/index")).request(new HttpCallbackProxy<HttpData<InviteModel>>(this){
            @Override
            public void onHttpSuccess(HttpData<InviteModel> result, boolean cache) {
                super.onHttpSuccess(result, cache);
                peopleView.setText(result.getData().getTotal_number());
                moneyView.setText(result.getData().getShare_money());
//                monthView.setText(result.getData().getMonth()+"");
//                totalView.setText(result.getData().getAccum_days()+"");
//                models =result.getData().getList();
//                m648Adapter.resetAdapterData(models);
            }
        });
    }




    @Override
    public void onItemClick(RecyclerView.ViewHolder viewHolder, View view, int position) {

    }





    @OnClick(R.id.actvity_back)
    public void onBackClick(){
        finish();
    }

    @OnClick(R.id.signin_rule)
    public void onRuleClick(){
        Intent in=new Intent(InviteActivity.this,DocumentActivity.class);
        in.putExtra("question_id","21");
        startActivity(in);
    }

    @OnClick(R.id.invite_confirm)
    public void onConfirmClick(){

        EasyHttp.post(this).api(new CommonApi("api/promotion/link")).request(new HttpCallbackProxy<HttpData<InviteModel>>(this){
            @Override
            public void onHttpSuccess(HttpData<InviteModel> result, boolean cache) {
                super.onHttpSuccess(result, cache);
                new InviteConfirmDialog.Builder(InviteActivity.this).setMessage(result.getData().getUrl()).create().show();
            }
        });


    }














//    @OnClick(R.id.actvity_back)
//    public void onBackClick(){
//        finish();
//    }
    @Override
    protected int getViewLayoutResourceId() {
        return R.layout.actviity_invite;
    }




}
